﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Jb.Search.TextExtractor;

namespace Jb.Search
{
    public class TextExtractorFactory
    {
        /// <summary>
        /// Gets a compatible text extractor object for the given file
        /// </summary>
        /// <param name="documentPath"></param>
        /// <returns>Returns a Compatible extractor depending on the document type. Otherwise a null object is returned</returns>
        public static ITextExtractor GetExtractor(String documentPath)
        {
            String extension = Path.GetExtension(documentPath);
            //if (String.Compare(extension, ".doc", true) == 0)
            //    return new MsWordDocument(documentPath);
            if (String.Compare(extension, ".docx", true) == 0)
                return new MsWordDocument(documentPath);
            else if (String.Compare(extension, ".pdf", true) == 0)
                return new PdfDocument(documentPath);
            else if (String.Compare(extension, ".txt", true) == 0)
                return new TextDocument(documentPath);

            return null;
        }
    }
}
